<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 4.2.1">
  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/dute_favicon_32x32.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/dute_favicon_16x16.png">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">
  <link rel="manifest" href="/images/manifest.json">
  <meta name="msapplication-config" content="/images/browserconfig.xml">
  <meta http-equiv="Cache-Control" content="no-transform">
  <meta http-equiv="Cache-Control" content="no-siteapp">
  <meta name="google-site-verification" content="mpI5dkydstZXl6UcDCppqktXK0bbvqdZ6LkZ3KNk4Iw">
  <meta name="baidu-site-verification" content="code-a1LksZX2Ds">

<link rel="stylesheet" href="/css/main.css">


<link rel="stylesheet" href="/lib/font-awesome/css/font-awesome.min.css">
  <link rel="stylesheet" href="//cdn.jsdelivr.net/gh/fancyapps/fancybox@3/dist/jquery.fancybox.min.css">

<script id="hexo-configurations">
    var NexT = window.NexT || {};
    var CONFIG = {"hostname":"whitestore.top","root":"/","scheme":"Gemini","version":"7.8.0","exturl":true,"sidebar":{"position":"left","display":"post","padding":18,"offset":12,"onmobile":false},"copycode":{"enable":true,"show_result":false,"style":null},"back2top":{"enable":true,"sidebar":true,"scrollpercent":true},"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":true,"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"algolia":{"hits":{"per_page":10},"labels":{"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}},"localsearch":{"enable":true,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},"path":"search.xml"};
  </script>

  <meta name="description" content="G1调优的大致思路">
<meta property="og:type" content="article">
<meta property="og:title" content="深入理解JVM - G1调优简述">
<meta property="og:url" content="https://whitestore.top/2021/12/25/g1tiaoyou/index.html">
<meta property="og:site_name" content="爱看书的阿东">
<meta property="og:description" content="G1调优的大致思路">
<meta property="og:locale" content="zh_CN">
<meta property="article:published_time" content="2021-12-25T04:11:01.000Z">
<meta property="article:modified_time" content="2023-07-16T06:28:09.267Z">
<meta property="article:author" content="阿东">
<meta property="article:tag" content="G1">
<meta property="article:tag" content="调优">
<meta name="twitter:card" content="summary">

<link rel="canonical" href="https://whitestore.top/2021/12/25/g1tiaoyou/">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome : false,
    isPost : true,
    lang   : 'zh-CN'
  };
</script>

  <title>深入理解JVM - G1调优简述 | 爱看书的阿东</title>
  






  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

<link rel="alternate" href="/atom.xml" title="爱看书的阿东" type="application/atom+xml">
</head>

<body itemscope itemtype="http://schema.org/WebPage">
  <div class="container use-motion">
    <div class="headband"></div>

    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏">
      <span class="toggle-line toggle-line-first"></span>
      <span class="toggle-line toggle-line-middle"></span>
      <span class="toggle-line toggle-line-last"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <h1 class="site-title">爱看书的阿东</h1>
      <span class="logo-line-after"><i></i></span>
    </a>
      <p class="site-subtitle" itemprop="description">赐他一块白色石头，石头上写着新名</p>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
        <i class="fa fa-search fa-fw fa-lg"></i>
    </div>
  </div>
</div>




<nav class="site-nav">
  <ul id="menu" class="menu">
        <li class="menu-item menu-item-home">

    <a href="/" rel="section"><i class="fa fa-fw fa-home"></i>首页</a>

  </li>
        <li class="menu-item menu-item-tags">

    <a href="/tags/" rel="section"><i class="fa fa-fw fa-tags"></i>标签</a>

  </li>
        <li class="menu-item menu-item-categories">

    <a href="/categories/" rel="section"><i class="fa fa-fw fa-th"></i>分类</a>

  </li>
        <li class="menu-item menu-item-archives">

    <a href="/archives/" rel="section"><i class="fa fa-fw fa-archive"></i>归档</a>

  </li>
        <li class="menu-item menu-item-sitemap">

    <a href="/sitemap.xml" rel="section"><i class="fa fa-fw fa-sitemap"></i>站点地图</a>

  </li>
      <li class="menu-item menu-item-search">
        <a role="button" class="popup-trigger"><i class="fa fa-search fa-fw"></i>搜索
        </a>
      </li>
  </ul>
</nav>



  <div class="search-pop-overlay">
    <div class="popup search-popup">
        <div class="search-header">
  <span class="search-icon">
    <i class="fa fa-search"></i>
  </span>
  <div class="search-input-container">
    <input autocomplete="off" autocapitalize="off"
           placeholder="搜索..." spellcheck="false"
           type="search" class="search-input">
  </div>
  <span class="popup-btn-close">
    <i class="fa fa-times-circle"></i>
  </span>
</div>
<div id="search-result">
  <div id="no-result">
    <i class="fa fa-spinner fa-pulse fa-5x fa-fw"></i>
  </div>
</div>

    </div>
  </div>

</div>
    </header>

    

  <span class="exturl github-corner" data-url="aHR0cHM6Ly9naXRodWIuY29tL2xhenlUaW1lcw==" title="Follow me on GitHub" aria-label="Follow me on GitHub"><svg width="80" height="80" viewBox="0 0 250 250" aria-hidden="true"><path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path><path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path><path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"></path></svg></span>


    <main class="main">
      <div class="main-inner">
        <div class="content-wrap">
          

          <div class="content post posts-expand">
            

    
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://whitestore.top/2021/12/25/g1tiaoyou/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="阿东">
      <meta itemprop="description" content="随遇而安">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="爱看书的阿东">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          深入理解JVM - G1调优简述
        </h1>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2021-12-25 12:11:01" itemprop="dateCreated datePublished" datetime="2021-12-25T12:11:01+08:00">2021-12-25</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="fa fa-calendar-check-o"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2023-07-16 14:28:09" itemprop="dateModified" datetime="2023-07-16T14:28:09+08:00">2023-07-16</time>
              </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/JVM/" itemprop="url" rel="index"><span itemprop="name">JVM</span></a>
                </span>
            </span>

          
            <span class="post-meta-item" title="阅读次数" id="busuanzi_container_page_pv" style="display: none;">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span id="busuanzi_value_page_pv"></span>
            </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2021/12/25/g1tiaoyou/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2021/12/25/g1tiaoyou/" itemprop="commentCount"></span>
    </a>
  </span>
  
  <br>
            <span class="post-meta-item" title="本文字数">
              <span class="post-meta-item-icon">
                <i class="fa fa-file-word-o"></i>
              </span>
                <span class="post-meta-item-text">本文字数：</span>
              <span>2.8k</span>
            </span>
            <span class="post-meta-item" title="阅读时长">
              <span class="post-meta-item-icon">
                <i class="fa fa-clock-o"></i>
              </span>
                <span class="post-meta-item-text">阅读时长 &asymp;</span>
              <span>3 分钟</span>
            </span>
            <div class="post-description">G1调优的大致思路</div>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
        <h1 id="深入理解JVM-G1调优简述"><a href="#深入理解JVM-G1调优简述" class="headerlink" title="深入理解JVM - G1调优简述"></a>深入理解JVM - G1调优简述</h1><h1 id="前言"><a href="#前言" class="headerlink" title="前言"></a>前言</h1><p>​    G1收集器是一个不太好调优的收集器，因为他不能像固定分代的收集器那样可以自己想划分多少就划分多少，更多的分配动作是由收集器动作，由于region是一块块的，同时自动增长也是由G1控制，好像确实不太好调优。</p>
<p>​    这篇文章更多的是提供调优的一个大致方向，更多的内容需要后续介绍JVM的工具进行讲解。</p>
<h1 id="案例实战"><a href="#案例实战" class="headerlink" title="案例实战"></a>案例实战</h1><p>​    这次使用一个在线的教育平台作为案例解释G1是如何进行优化的。</p>
<p>​    在线教育平台的压力来自于哪里？首先孩子白天需要上学同时家长也需要上班，所以白天的访问量不会很大，同时主要的业务也不在在线教育平台处理。但是一旦到了晚上，机器的压力就上来了，同时孩子也会在线进行听课上课，这时候用户量会暴增，会有上万人同时在线听课。这时候可以发现在线教育平台的压力在于直播，而直播的流量高峰在于课堂的互动环节，为什么是互动环节呢，因为孩子不喜欢枯燥的课堂，为了带动课堂氛围，课堂中的游戏一定是活跃气氛的关键，也是系统压力的核心，这时系统需要记录各种数据，比如活动时长，得分，积分奖励等等，同时也会出现大量的对象分配，为了保证直播的流畅，系统要求十分低的延迟响应时间。</p>
<p>​    所以最终的结论是：在线教育平台大概在直播的互动环节压力会倍增，系统要求十分低的延迟响应时间。</p>
<p>​    经过了上面的情况分析，我们假设<strong>单台机器每秒大概有600个请求</strong>，假设每一个请求占用10KB，则是6000KB的大小占用也就是最终6M左右的内存占用。同时部署在一个4核心8G的系统上面。</p>
<blockquote>
<p>同样的，这种案例也只是模拟和假设，具体情况受到各种因素的限制，切勿过于深究细节。</p>
</blockquote>
<h1 id="如何分析系统"><a href="#如何分析系统" class="headerlink" title="如何分析系统"></a>如何分析系统</h1><h2 id="传统的分代概念"><a href="#传统的分代概念" class="headerlink" title="传统的分代概念"></a>传统的分代概念</h2><p>​    我们用传统分代的概念部署一下这个系统，根据每一秒的请求为6M的对象大小，同时根据系统4核心8的配置，那么给JVM的内存大概是4G，我们知道直播的互动环节产生的积分，奖励，计算等对象基本都是朝生夕死的小对象，所以我们不太需要给老年代过大的空间，所以出去方法区和虚拟机线程栈的内存，我们给大约会给新生代3G和老年代1G左右的内容。</p>
<p>​    如果每秒产生6M的对象，那么一分钟就是300多M，按照默认的新生代配比8：1：1则Eden区域大概为2.4G的大小，survior区域为两个300M的大小空间。一分钟300M，那么基本上8分钟左右新生代就会满，此时假设有300M左右对象存活进入Survior区域，这时候Survior区域虽然可以装的下，但是由于超过了50%的配比，最终还是有约150M的对象进入老年代。</p>
<p>​    这时候再推算，老年代每8分钟进入150M的对象，大约40分钟左右就会整个系统停顿一次，这个停顿时间还是乐观估计，因为系统不可能只运作这一块的内容，单单是推算直播互动这一块就会产生这样的效果，可想而知加上整个系统的其他模块，<strong>实际上5、6分钟可能会停顿一次！！！</strong>这样肯定是不行的，试想下你玩游戏隔几分钟就停一下，对于小孩子来说突然卡一下导致丢分最后成绩不佳孩子又哭又闹，家长这时候不用想肯定会大量的投诉，被骂也不远了……</p>
<h2 id="使用G1收集器"><a href="#使用G1收集器" class="headerlink" title="使用G1收集器"></a>使用G1收集器</h2><p>​    我们接着使用G1的收集器进行替换，系统部署在一个4核心8G的系统上面，假设机器在JVM上分配4G给堆，新生代默认初始化比例为5%，最大占比为60%，JAVA线程堆栈为1M，则大约开启几百个线程需要200，300M的空间，而方法区占用256M够用。</p>
<p>​    在上一节在文章中介绍过，可以把G1的工作机制想象成收盘子，但是放到系统上就很头疼了，<strong>G1什么时候回来收垃圾是我们无法预测的！！</strong>这里就需要通过一些辅助手段，同时这部分的监控操作需要工具和日志进行解读，所以将会放到后续的专门一篇文章进行解读。</p>
<h3 id="如何计算Region的占用和大小："><a href="#如何计算Region的占用和大小：" class="headerlink" title="如何计算Region的占用和大小："></a>如何计算Region的占用和大小：</h3><p>​    按照4096M/2048 每个region是2M，如果按照新生代初始为5%，则根据参数5%新生代的大小为100个Region左右，4G的内存机器结果可以得出新生代初始200M左右的内存占用大小</p>
<h3 id="至关重要的参数："><a href="#至关重要的参数：" class="headerlink" title="至关重要的参数："></a>至关重要的参数：</h3><p>​    <strong>-XX:MaxGCPauseMills</strong> 参数：默认值为200，代表了200MS，表示最大的停顿时间为200MS。</p>
<p>​    如果使用G1收集器，这个参数直接影响了整个JVM系统的性能，如果这个数值过大，会导致垃圾收集的时间过长而导致前台卡顿，也容易导致新生代来不及触发垃圾回收就满了，或者导致老年代内存无法及时的回收。</p>
<h3 id="多久会触发新生代回收操作"><a href="#多久会触发新生代回收操作" class="headerlink" title="多久会触发新生代回收操作"></a>多久会触发新生代回收操作</h3><p>​    根据之前的说明，<strong>新生代最大可以使用60%的空间</strong>，同时也说明了新生代使用复制算法，根据8:1:1的规则，大概到达新生代的80%左右就会触发垃圾的回收操作？这种做法显然不符合G1基于全堆以及混合回收的操作。所以不能用固定大小的回收思路思考g1的回收操作。</p>
<p>​    正确做法：    G1会根据200MS的要求，定时去判定当前的新生代是否可以符合200MS的收集操作要求，大意就是当新生代的垃圾回收需要耗时200MS的时候，就会触发新生代的回收。</p>
<p>​    这里也可以直接按照之前的理解餐厅的服务员定时过来收盘子的操作理解新生代多久进行一次回收操作。</p>
<h3 id="如何优化："><a href="#如何优化：" class="headerlink" title="如何优化："></a>如何优化：</h3><p>​    上面的讨论几点之后，这就头疼了，这要这么优化？这时我们需要用上一些压测的工具以及GC日志和内存分析工具来考虑了，但是也不要让GC挺多停顿时间预设值太大了导致GC停顿时间太长，应该给个合理的值。</p>
<h3 id="Mixed-gc如何优化？"><a href="#Mixed-gc如何优化？" class="headerlink" title="Mixed gc如何优化？"></a>Mixed gc如何优化？</h3><p>​    既然新生代的优化都已经很麻烦了，更不用说老年代回收了。而老年代的回收本身也没有了Old GC，取而代之的是Mixed GC，所以需要小心对待，我们从根本上还是需要防止让对象进入到老年代不断扩展导致mixed gc，这更加需要关注时间停顿模型这个参数。</p>
<h2 id="最终分析"><a href="#最终分析" class="headerlink" title="最终分析"></a>最终分析</h2><p>​    新生代：</p>
<ol>
<li>由于是复制算法，所以需要从根本上处理的话依然需要控制新生代的存活对象进入survior的大小，同时控制在50%以内。尽量避免GC之后对象直接进入老年代。另外60%的新生代空间通常也不用怎么调整，除非业务对象频繁创建新生代会产生大量对象才需要考虑。</li>
<li>新生代有一个参数是存活对象大于85%的时候不需要进行拷贝，这个值如果设置小一点可能会提高回收效率，但是有可能造成大量的短命对象进入老年代的风险。</li>
</ol>
<p>​    老年代：</p>
<ol>
<li>按照G1的最后一个步骤，垃圾回收和系统回交替8次，同时在回到5%的region的时候停止收集，这个参数其实可以适当调大一些：G1HeapWastePercent</li>
<li>45%的老年代占用触发垃圾回收的机制，这个参数也不需要大改，因为JDK设置这个参数肯定是经过了很多测试和考量之后的结果。</li>
</ol>
<h2 id="总结"><a href="#总结" class="headerlink" title="总结"></a>总结</h2><p>​    这一篇更多的是提供优化思路，JVM调优没有万金油的解决方案，特别是G1收集器这种算法细节十分复杂的收集器，调优需要更多的精力和时间测试调优效果。</p>
<h1 id="写在最后"><a href="#写在最后" class="headerlink" title="写在最后"></a>写在最后</h1><p>​    下一篇章会做一个整个系列到目前为止的小节，温故而知新，人的遗忘曲线更加需要我们反复的巩固知识和内容。</p>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/kity@2.0.4/dist/kity.min.js"></script><script type="text/javascript" src="https://cdn.jsdelivr.net/npm/kityminder-core@1.4.50/dist/kityminder.core.min.js"></script><script defer="true" type="text/javascript" src="https://cdn.jsdelivr.net/npm/hexo-simple-mindmap@0.2.0/dist/mindmap.min.js"></script><link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/hexo-simple-mindmap@0.2.0/dist/mindmap.min.css">
    </div>

    
    
    
        

<div>
<ul class="post-copyright">
  <li class="post-copyright-author">
    <strong>本文作者： </strong>lazytime
  </li>
  <li class="post-copyright-link">
    <strong>本文链接：</strong>
    <a href="https://whitestore.top/2021/12/25/g1tiaoyou/" title="深入理解JVM - G1调优简述">https://whitestore.top/2021/12/25/g1tiaoyou/</a>
  </li>
  <li class="post-copyright-license">
    <strong>版权声明： </strong>本博客所有文章除特别声明外，均采用 <span class="exturl" data-url="aHR0cHM6Ly9jcmVhdGl2ZWNvbW1vbnMub3JnL2xpY2Vuc2VzL2J5LW5jLzQuMC96aC1DTg=="><i class="fa fa-fw fa-creative-commons"></i>BY-NC</span> 许可协议。转载请注明出处！
  </li>
</ul>
</div>


      <footer class="post-footer">
          <div class="post-tags">
              <a href="/tags/JVM/" rel="tag"># JVM</a>
          </div>

        


        
    <div class="post-nav">
      <div class="post-nav-item">
    <a href="/2021/12/25/g1garbage/" rel="prev" title="深入理解JVM - G1收集器">
      <i class="fa fa-chevron-left"></i> 深入理解JVM - G1收集器
    </a></div>
      <div class="post-nav-item">
    <a href="/2022/01/28/mycms/" rel="next" title="深入理解JVM - CMS收集器">
      深入理解JVM - CMS收集器 <i class="fa fa-chevron-right"></i>
    </a></div>
    </div>
      </footer>
    
  </article>
  
  
  



          </div>
          
    <div class="comments" id="valine-comments"></div>

<script>
  window.addEventListener('tabs:register', () => {
    let { activeClass } = CONFIG.comments;
    if (CONFIG.comments.storage) {
      activeClass = localStorage.getItem('comments_active') || activeClass;
    }
    if (activeClass) {
      let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
      if (activeTab) {
        activeTab.click();
      }
    }
  });
  if (CONFIG.comments.storage) {
    window.addEventListener('tabs:click', event => {
      if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
      let commentClass = event.target.classList[1];
      localStorage.setItem('comments_active', commentClass);
    });
  }
</script>

        </div>
          
  
  <div class="toggle sidebar-toggle">
    <span class="toggle-line toggle-line-first"></span>
    <span class="toggle-line toggle-line-middle"></span>
    <span class="toggle-line toggle-line-last"></span>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
          <div class="post-toc motion-element"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#深入理解JVM-G1调优简述"><span class="nav-number">1.</span> <span class="nav-text">深入理解JVM - G1调优简述</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#前言"><span class="nav-number">2.</span> <span class="nav-text">前言</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#案例实战"><span class="nav-number">3.</span> <span class="nav-text">案例实战</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#如何分析系统"><span class="nav-number">4.</span> <span class="nav-text">如何分析系统</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#传统的分代概念"><span class="nav-number">4.1.</span> <span class="nav-text">传统的分代概念</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#使用G1收集器"><span class="nav-number">4.2.</span> <span class="nav-text">使用G1收集器</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#如何计算Region的占用和大小："><span class="nav-number">4.2.1.</span> <span class="nav-text">如何计算Region的占用和大小：</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#至关重要的参数："><span class="nav-number">4.2.2.</span> <span class="nav-text">至关重要的参数：</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#多久会触发新生代回收操作"><span class="nav-number">4.2.3.</span> <span class="nav-text">多久会触发新生代回收操作</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#如何优化："><span class="nav-number">4.2.4.</span> <span class="nav-text">如何优化：</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#Mixed-gc如何优化？"><span class="nav-number">4.2.5.</span> <span class="nav-text">Mixed gc如何优化？</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#最终分析"><span class="nav-number">4.3.</span> <span class="nav-text">最终分析</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#总结"><span class="nav-number">4.4.</span> <span class="nav-text">总结</span></a></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#写在最后"><span class="nav-number">5.</span> <span class="nav-text">写在最后</span></a></li></ol></div>
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
  <p class="site-author-name" itemprop="name">阿东</p>
  <div class="site-description" itemprop="description">随遇而安</div>
</div>
<div class="site-state-wrap motion-element">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/archives/">
        
          <span class="site-state-item-count">239</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
            <a href="/categories/">
          
        <span class="site-state-item-count">36</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
            <a href="/tags/">
          
        <span class="site-state-item-count">37</span>
        <span class="site-state-item-name">标签</span></a>
      </div>
  </nav>
</div>
  <div class="links-of-author motion-element">
      <span class="links-of-author-item">
        <span class="exturl" data-url="aHR0cHM6Ly9naXRodWIuY29tL2xhenlUaW1lcw==" title="GitHub → https:&#x2F;&#x2F;github.com&#x2F;lazyTimes"><i class="fa fa-fw fa-github"></i>GitHub</span>
      </span>
      <span class="links-of-author-item">
        <span class="exturl" data-url="bWFpbHRvOjEwOTc0ODM1MDhAcXEuY29t" title="E-Mail → mailto:1097483508@qq.com"><i class="fa fa-fw fa-envelope"></i>E-Mail</span>
      </span>
  </div>


  <div class="links-of-blogroll motion-element">
    <div class="links-of-blogroll-title">
      <i class="fa fa-fw fa-link"></i>
      友情链接
    </div>
    <ul class="links-of-blogroll-list">
        <li class="links-of-blogroll-item">
          <span class="exturl" data-url="aHR0cHM6Ly93d3cuNTJwb2ppZS5jbi9ob21lLnBocD9tb2Q9c3BhY2UmdWlkPTE0OTc3MTgmZG89dGhyZWFkJnZpZXc9bWUmZnJvbT1zcGFjZQ==" title="https:&#x2F;&#x2F;www.52pojie.cn&#x2F;home.php?mod&#x3D;space&amp;uid&#x3D;1497718&amp;do&#x3D;thread&amp;view&#x3D;me&amp;from&#x3D;space">吾爱破解</span>
        </li>
        <li class="links-of-blogroll-item">
          <span class="exturl" data-url="aHR0cHM6Ly9qdWVqaW4uaW0vdXNlci8yOTk5MTIzNDUyNjI2MzY2" title="https:&#x2F;&#x2F;juejin.im&#x2F;user&#x2F;2999123452626366">掘金</span>
        </li>
        <li class="links-of-blogroll-item">
          <span class="exturl" data-url="aHR0cHM6Ly9zZWdtZW50ZmF1bHQuY29tL3UvbGF6eXRpbWVz" title="https:&#x2F;&#x2F;segmentfault.com&#x2F;u&#x2F;lazytimes">思否</span>
        </li>
    </ul>
  </div>

      </div>

      <div class="wechat_OA">
        <span>欢迎关注我的公众号</span>
        <br>
          <!-- 这里添加你的二维码图片 -->
        <img src ="https://adong-picture.oss-cn-shenzhen.aliyuncs.com/adong/wechat_channel.jpg">
      </div>
        <div class="back-to-top motion-element">
          <i class="fa fa-arrow-up"></i>
          <span>0%</span>
        </div>

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer class="footer">
      <div class="footer-inner">
        

        

<div class="copyright">
  
  &copy; 
  <span itemprop="copyrightYear">2023</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">阿东</span>
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item-icon">
      <i class="fa fa-area-chart"></i>
    </span>
      <span class="post-meta-item-text">站点总字数：</span>
    <span title="站点总字数">2m</span>
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item-icon">
      <i class="fa fa-coffee"></i>
    </span>
      <span class="post-meta-item-text">站点阅读时长 &asymp;</span>
    <span title="站点阅读时长">29:50</span>
</div>
  <div class="powered-by">由 <span class="exturl theme-link" data-url="aHR0cHM6Ly9oZXhvLmlv">Hexo</span> & <span class="exturl theme-link" data-url="aHR0cHM6Ly90aGVtZS1uZXh0Lm9yZw==">NexT.Gemini</span> 强力驱动
  </div>

        
<div class="busuanzi-count">
  <script async src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
    <span class="post-meta-item" id="busuanzi_container_site_uv" style="display: none;">
      <span class="post-meta-item-icon">
        <i class="fa fa-user"></i>
      </span>
      <span class="site-uv" title="总访客量">
        <span id="busuanzi_value_site_uv"></span>
      </span>
    </span>
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item" id="busuanzi_container_site_pv" style="display: none;">
      <span class="post-meta-item-icon">
        <i class="fa fa-eye"></i>
      </span>
      <span class="site-pv" title="总访问量">
        <span id="busuanzi_value_site_pv"></span>
      </span>
    </span>
</div>








      </div>
    </footer>
  </div>

  
  <script src="/lib/anime.min.js"></script>
  <script src="//cdn.jsdelivr.net/npm/jquery@3/dist/jquery.min.js"></script>
  <script src="//cdn.jsdelivr.net/gh/fancyapps/fancybox@3/dist/jquery.fancybox.min.js"></script>
  <script src="/lib/velocity/velocity.min.js"></script>
  <script src="/lib/velocity/velocity.ui.min.js"></script>

<script src="/js/utils.js"></script>

<script src="/js/motion.js"></script>


<script src="/js/schemes/pisces.js"></script>


<script src="/js/next-boot.js"></script>




  




  
<script src="/js/local-search.js"></script>













  

  


<script>
NexT.utils.loadComments(document.querySelector('#valine-comments'), () => {
  NexT.utils.getScript('//unpkg.com/valine/dist/Valine.min.js', () => {
    var GUEST = ['nick', 'mail', 'link'];
    var guest = 'nick,mail,link';
    guest = guest.split(',').filter(item => {
      return GUEST.includes(item);
    });
    new Valine({
      el         : '#valine-comments',
      verify     : false,
      notify     : true,
      appId      : 'qMUpEEvBgXaMDD1b0ftgi9xr-gzGzoHsz',
      appKey     : 'UCdfT4Rfih6MO6y8DI4fstf6',
      placeholder: "Just go go",
      avatar     : 'mm',
      meta       : guest,
      pageSize   : '10' || 10,
      visitor    : false,
      lang       : 'zh-CN' || 'zh-cn',
      path       : location.pathname,
      recordIP   : false,
      serverURLs : ''
    });
  }, window.Valine);
});
</script>

</body>
</html>
